﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Student a1 = new Student(1, "实际", 18);
            Student a2 = new Student(2, "完事", 17);
            Student a3 = new Student(3, "是否", 19);
            List<Student> list = new List<Student>();
            Student ht = new Student();
            list.Add(a1);
            list.Add(a2);
            list.Add(a3);


            ht.CompareTo(a1._stuid, a1);
            ht.CompareTo(a2._stuid, a2);
            ht.CompareTo(a3._stuid, a3);

            Text();
            Console.WriteLine("请选择：1、添加学生信息 2、查询学生信息");
            int key = int.Parse(Console.ReadLine());
            switch (key)
            {
                case 1:
                    AddStudent();
                    break;
                case 2:
                    ChaXun();
                    break;
                default:
                    break;
            }
            void ChaXun()//查询学生信息 
            {
                Console.WriteLine("--------------------------------------------------------------------------");
                Console.WriteLine("1、查询所有（按学号排序）2、查询所有（按姓名排序）6、返回上一级");
                Console.WriteLine("                  ------------------------                 ");
                Console.WriteLine("3、查询所有（按年龄排序）4、按学号查询（查没有，则打印查无此学生）5、退出");
                int key1 = int.Parse(Console.ReadLine());
                Student ht = new Student();
                switch (key)
                {
                    case 1:
                        list.Sort(new Nun());
                        list.Reverse();
                        foreach (var s in list)
                        {
                            Console.WriteLine(s);
                        }
                        ChaXun();
                        break;
                    case 2:
                        list.Sort(new Name());
                        foreach (var s in list)
                        {
                            Console.WriteLine(s);
                        }
                        ChaXun();
                        break;
                    case 3:
                        list.Sort(new Age());
                        foreach (var s in list)
                        {
                            Console.WriteLine(s);
                        }
                        ChaXun();
                        break;
                    case 4:
                        Console.WriteLine("请输入学号：");
                        int i = int.Parse(Console.ReadLine());
                        if (ht.Contains(i))
                        {
                            Console.WriteLine(ht[i]);
                        }
                        else
                        {
                            Console.WriteLine("该学生不存在!!!");
                        }

                        ChaXun();
                        break;
                    case 5:
                        Console.WriteLine("程序结束！！");
                        break;
                    case 6:
                        Text();
                        break;
                    default:
                        Console.WriteLine("输入有误！请重新输入！！");
                        ChaXun();
                        break;
                }

                 void AddStudent()//添加学生信息
                {
                    Console.WriteLine("请输入学号：");
                    int stuid = int.Parse(Console.ReadLine());
                    Console.WriteLine("请输入姓名：");
                    string name = Console.ReadLine();
                    Console.WriteLine("请输入年龄");
                    int age = int.Parse(Console.ReadLine());
                    Student ss = new Student(stuid, name, age);

                    if (ht.Contains(stuid))
                    {
                        Console.WriteLine("该学号已存在！！");
                        AddStudent();
                    }
                    else
                    {
                        list.Add(ss);
                        ht.Add(ss._stuid, ss);
                        Text();
                    }


                }
            }
        }

        private static void AddStudent()
        {
            throw new NotImplementedException();
        }

        private static void Text()
        {
            throw new NotImplementedException();
        }
    }
}
